using AnQinFrameWorkAPI.Entity.Finance.DTO.FinanceUser;
using AnQinFrameWorkAPI.Entity.Finance.View.FinanceUser;
using AnQinFrameWorkAPI.Service.Finance;
using FrameWork.Entity;
using Microsoft.AspNetCore.Mvc;

namespace AnQinFrameWorkAPI.Controllers.Finance;

/// <summary>
///     财务用户API
/// </summary>
[Route("api/[controller]")]
[ApiController]
[ApiExplorerSettings(GroupName = "Finance")]
public class FinanceUserController : ControllerBase
{
    //业务接口
    private readonly FinanceUserService _financeUserService;

    //构造注入
    public FinanceUserController(FinanceUserService financeUserService)
    {
        _financeUserService = financeUserService;
    }

    /// <summary>
    ///     获取财务用户列表
    /// </summary>
    [ProducesResponseType(typeof(FinanceUserView), 200)]
    [HttpGet]
    public async Task<IActionResult> GetFinanceUserList([FromQuery] FinanceUserSearchDTO financeUserSearchDTO)
    {
        var response = await _financeUserService.GetFinanceUserList(financeUserSearchDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     新增财务用户
    /// </summary>
    [HttpPost]
    public async Task<IActionResult> AddFinanceUser([FromBody] FinanceUserAddDTO financeUserAddDTO)
    {
        var response = await _financeUserService.AddFinanceUser(financeUserAddDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     编辑财务用户
    /// </summary>
    [HttpPut]
    public async Task<IActionResult> PutFinanceUser([FromBody] FinanceUserUpdateDTO financeUserUpdateDTO)
    {
        var response = await _financeUserService.PutFinanceUser(financeUserUpdateDTO);
        return StatusCode(response.Status, response);
    }

    /// <summary>
    ///     删除财务用户
    /// </summary>
    [HttpDelete]
    public async Task<IActionResult> DeleteFinanceUser([FromBody] SingleIdDTO deleteDTO)
    {
        var response = await _financeUserService.DeleteFinanceUser(deleteDTO);
        return StatusCode(response.Status, response);
    }
}